package edu.xidian.bdilab.jrbigdata.controller.bank;

import edu.xidian.bdilab.jrbigdata.controller.response.ResponseResult;
import edu.xidian.bdilab.jrbigdata.service.bank.productApplyCheck.ProductApplyService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.text.ParseException;

/**
 * @ClassName ProductApplyController
 * @Attention Copyright (C), 2004-2019, BDILab, XiDian University
 **/
@RestController
@Api(tags = {"ProductApply-企业申请查看和成交"})
public class ProductApplyController {
    @Autowired
    ProductApplyService productApplyService;
    /*
    * 企业申请查看
    */
    @PostMapping(value = "bank/productApply")
    ResponseResult productApply(@RequestParam String bankName){
        ResponseResult responseResult = new ResponseResult();
        responseResult.setData(productApplyService.getAllProRequest(bankName));
        responseResult.setSuccess(true);
        responseResult.setCode(BankCode.PRODUCT_APPLY_SUCCESS.getCode());
        responseResult.setMessage(BankCode.PRODUCT_APPLY_SUCCESS.getMessage());

        return responseResult;
    }


    /*
     * 企业申请成交
     */
    @PostMapping(value = "bank/productDeal")
    ResponseResult productDeal(@RequestParam int request_id) throws ParseException {
        ResponseResult responseResult = productApplyService.productDeal(request_id);
        return responseResult;
    }

    /*
     * 企业申请拒绝
     */
    @PostMapping(value = "bank/productApplyRefuse")
    ResponseResult productApplyRefuse(@RequestParam int request_id) throws ParseException {
        ResponseResult responseResult = productApplyService.productApplyRefuse(request_id);
        return responseResult;
    }
    /*
    * 查看成交记录
    */
    @PostMapping(value = "bank/getProductDeal")
    ResponseResult getProductDeal(@RequestParam(defaultValue = "1")@ApiParam(value = "页码") int pageNum,
                                  @RequestParam(defaultValue = "10")@ApiParam(value = "每页记录数") int pageSize){
        ResponseResult responseResult = productApplyService.getProductDeal(pageNum, pageSize);
        return responseResult;
}

    /*
     * 修改产品申请进度
     */
    @PostMapping(value = "bank/modifyApplySchedule")
    ResponseResult modifyApplySchedule(@RequestParam int request_id,
                                       @RequestParam String Comment){
        ResponseResult responseResult = productApplyService.modifyApplySchedule(request_id, Comment);
        return responseResult;
    }

}
